/**
 * Created with JetBrains WebStorm.
 * User: renji
 * Date: 14/5/13
 * Time: 12:50 PM
 * To change this template use File | Settings | File Templates.
 */

describe("MoveSummaryController unit test", function(){

    var authoriseSummaryController = null;

    beforeEach(function(){


        var t_alertCtrl = App.AlertController.create();
        var t_loadingCtrl = App.LoadingController.create();
        App.AuthoriseTransactionSummaryController.reopen({

            init:function(){
                this.set('controllers.alert', t_alertCtrl);
                this.set('controllers.loading', t_loadingCtrl);
            }
        });

        authoriseSummaryController = App.AuthoriseTransactionSummaryController.create();
        authoriseSummaryController.summaryListViewData = Ember.Object.create({
            displayList: []
        });
    });
    describe("controller unit test", function(){


        it("prepareController unit test", function(){

            var transfer = App.OwnAccountTransfer.create();
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(transfer);
            spyOn(authoriseSummaryController, 'set');
            spyOn(authoriseSummaryController, 'resetProperties');

            authoriseSummaryController.prepareController();

            expect(App.getSession().getCurrentTransfer).toHaveBeenCalled();
            expect(authoriseSummaryController.set).toHaveBeenCalledWith('transfer', transfer);
            expect(authoriseSummaryController.resetProperties).toHaveBeenCalled();
        });

        it("resetProperties", function(){
            spyOn(authoriseSummaryController, 'set');
            authoriseSummaryController.resetProperties();
            expect(authoriseSummaryController.set).toHaveBeenCalledWith('showNotes', false);
            expect(authoriseSummaryController.set).toHaveBeenCalledWith('showHideText', "Show");
        });

        it("seeTransactionHistoryAction", function(){
            spyOn(App.RouteHistory, 'flush');
            spyOn(App.getSession(), 'deleteCurrentTransfer');
            spyOn(authoriseSummaryController, 'transitionTo');
            authoriseSummaryController.seeTransactionHistoryAction();
            expect(authoriseSummaryController.transitionTo).toHaveBeenCalled();
            expect(App.RouteHistory.flush).toHaveBeenCalled();
            expect(App.getSession().deleteCurrentTransfer).toHaveBeenCalled();
        });
    })
});